/*
 * Filename ReportMapping.java 2022年03月24日
 * Copyright © Ehome Co.Ltd. All Rgiths Reserved.
 * @author wuyingchao
 */
package com.ehome.poct.core.mapping;

import com.ehome.poct.core.api.dto.check.BldCheckReportVO;
import com.ehome.poct.core.api.dto.check.CheckProjectDTO;
import com.ehome.poct.core.api.dto.check.CheckReportDTO;
import com.ehome.poct.core.api.dto.checkdata.BldCheckDataDTO;
import com.ehome.poct.core.api.dto.patient.Patient;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

import java.time.LocalDateTime;
import java.util.Map;

/**
 * @author wyc
 * @since 2022/03/24 14:49
 **/
@Mapper(componentModel = "spring")
public interface TestReportSvcMapping {

    @Mapping(target = "patientId", source = "data.patientId")
    @Mapping(target = "patientName", source = "patient.detail.name")
    @Mapping(target = "payStatus", expression = "java(isPay ? 20 : 0)")
    @Mapping(target = "reportType", source ="project.type")
    @Mapping(target = "reportName", source = "project.checkProjectName")
    @Mapping(target = "projectCode", source = "project.checkProjectCode")
    @Mapping(target = "createTime", ignore = true)
    @Mapping(target = "createBy", ignore = true)
    @Mapping(target = "updateBy", ignore = true)
    @Mapping(target = "updateTime", ignore = true)
    @Mapping(target = "deleteTime", ignore = true)
    @Mapping(target = "traceId", ignore = true)
    @Mapping(target = "map", ignore = true)
    @Mapping(target = "wbcResultCode", expression = "java(codeMap.get(\"wbc\") + \"000000\")")
    @Mapping(target = "hgbResultCode", expression = "java(\"000000\" + codeMap.get(\"hgb\") + \"0000\")")
    @Mapping(target = "rdwResultCode", expression = "java(\"000000\" + codeMap.get(\"rdw\") + \"0\")")
    @Mapping(target = "hctResultCode", expression = "java(\"0000000000\" + codeMap.get(\"hct\") + \"0\")")
    @Mapping(target = "pltResultCode", expression = "java(\"00000000000\" + codeMap.get(\"plt\"))")
    CheckReportDTO to(BldCheckDataDTO data, CheckProjectDTO project, Patient patient, String orderNo , Map<String,String> codeMap,Boolean isPay);

    BldCheckReportVO to(CheckReportDTO dto, LocalDateTime checkTime);
}